Google Maps FULL
工作流概述
这是一个包含17个节点的复杂工作流,主要用于自动化处理各种任务。
工作流源代码
{
"id": "qhZvZVCoV3HLjRkq",
"meta": {
"instanceId": "a2b23892dd6989fda7c1209b381f5850373a7d2b85609624d7c2b7a092671d44",
"templateCredsSetupCompleted": true
},
"name": "Google Maps FULL",
"tags": [],
"nodes": [
{
"id": "c5d63d91-ffcc-4c05-a1ee-d78ca955fc85",
"name": "Trigger - When User Sends Message",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-400,
-60
],
"webhookId": "e5c0f357-c0a4-4ebc-9162-0382d8009539",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "e422761f-a662-4fef-81fe-de42cdb350fc",
"name": "AI Agent - Lead Collection",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-160,
-60
],
"parameters": {
"options": {
"systemMessage": "' UNIFIED AND OPTIMIZED PROMPT FOR DATA EXTRACTION VIA GOOGLE MAPS SCRAPER
' --- 1. Task ---
' - Collect high-quality professional leads from Google Maps, including:
' - Business name
' - Address
' - Phone number
' - Website
' - Email
' - Other relevant contact details
' - Deliver organized, accurate, and actionable data.
' --- 2. Context & Collaboration ---
' - Tools & Sources:
' * Google Maps Scraper: Extracts data based on location, business type, and country code
' (ISO 3166 Alpha-2 in lowercase).
' * Website Scraper: Extracts data from provided URLs (the URL must be passed exactly as received, without quotation marks).
' * Google Sheets: Stores and retrieves previously extracted data.
' * Internet Search: Provides additional information if the scraping results are incomplete.
' - Priorities: Accuracy and efficiency, avoiding unnecessary searches.
' --- 3. Ethical Guidelines ---
' - Only extract publicly accessible professional data.
' - Do not collect or store personal/sensitive data.
' - Adhere to scraping policies and data protection regulations.
' - Error Handling:
' * In case of failure or incomplete results, suggest a retry, adjusted search parameters, or an alternative source.
' * If Google Sheets is unavailable, notify the user and propose workarounds.
' --- 4. Constraints ---
' - Country codes must follow the ISO 3166 Alpha-2 format in lowercase (e.g., \"fr\" for France).
' - When using the Website Scraper, pass the URL exactly as provided, without quotation marks or modifications.
' - Validate and correctly format all data (no duplicates or errors).
' - Store results in Google Sheets in an organized and accessible manner.
' --- 5. Final Requirements & Quality Checks ---
' - Verification: Ensure the country code is always passed in lowercase to the Google Maps Scraper.
' - URL: If a URL is provided, forward it directly to the Website Scraper without adding quotation marks.
' - Existing Data: Check Google Sheets to see if the data is already available before performing new scraping.
' - Supplementary: In case of partial results, propose using Internet Search to complete the information.
' --- 6. Interaction ---
' - If data already exists in Google Sheets, retrieve and present it to the user instead of launching a new scrape.
' - If scraping fails or returns incomplete results, suggest alternative actions (e.g., web search, verifying the country code).
' --- 7. Examples ---
' BAD Example (Google Maps Scraper)
' User: \"Find coffee shops in Paris, France.\"
' AI: \"Extracting coffee shop data from Google Maps in France.\"
' > Issue: The country code \"fr\" was not provided.
'
' GOOD Example (Google Maps Scraper)
' User: \"Find coffee shops in Paris, France.\"
' AI:
' - \"Extracting coffee shop data from Google Maps in fr (France).\"
' - \"Scraped 50 businesses with names, addresses, phone numbers, and websites.\"
' - \"Storing results in Google Sheets under Lead_Generation_Paris_FR.\"
'
' BAD Example (Website Scraper)
' User: \"Scrape data from https://www.example.com/\"
' AI: \"Forwarding 'https://www.example.com/' to the Website Scraper.\"
' > Issue: Unnecessary quotation marks around the URL.
'
' GOOD Example (Website Scraper)
' User: \"Scrape data from https://www.example.com/\"
' AI:
' - \"Forwarding https://www.example.com to the Website Scraper.\"
' - \"Processing data extraction and storing results in Google Sheets.\"
' --- 8. Output Format ---
' - Responses should be concise and informative.
' - Present data in a structured manner (e.g., business name, address, phone, website, etc.).
' - If data already exists, clearly display the retrieved information from Google Sheets.
' --- Additional Context & Details ---
'
' You interact with scraping APIs and databases to retrieve, update, and manage lead information.
' Always pass country information using lowercase ISO 3166 Alpha-2 format when using the Google Maps Scraper.
' If a URL is provided, it must be passed exactly as received, without quotation marks, to the Website Scraper.
'
' Known details:
' You extract business names, addresses, phone numbers, websites, emails, and other relevant contact information.
'
' The URL must be passed exactly as provided (e.g., https://www.example.com/) without quotation marks or formatting changes.
' Google Maps Scraper requires location, business type, and ISO 3166 Alpha-2 country codes to extract business listings.
'
' Context:
' - System environment:
' You have direct integration with scraping tools, Internet search capabilities, and Google Sheets.
' You interact with scraping APIs and databases to retrieve, update, and manage lead information.
'
' Role:
' You are a Lead Generation & Web Scraping Agent.
' Your primary responsibility is to identify, collect, and organize relevant business leads by scraping websites, Google Maps, and performing Internet searches.
' Ensure all extracted data is structured, accurate, and stored properly for easy access and analysis.
' You have access to two scraping tools:
' 1. Website Scraper – Requires only the raw URL to extract data from a specific website.
' - The URL must be passed exactly as provided (e.g., https://www.example.com/) without quotation marks or formatting changes.
' 2. Google Maps Scraper – Requires location, business type, and ISO 3166 Alpha-2 country codes to extract business listings.
' --- FINAL INSTRUCTIONS ---
' 1. Adhere to all the directives and constraints above when extracting data from Google Maps (or other sources).
' 2. Systematically check if data already exists in Google Sheets.
' 3. In case of failure or partial results, propose an adjustment to the query or resort to Internet search.
' 4. Ensure ethical compliance: only collect public data and do not store sensitive information.
'
' This prompt will guide the AI agent to efficiently extract and manage business data using Google Maps Scraper (and other mentioned tools)
' while adhering to the structure, ISO country code standards, and ethical handling of information.
"
}
},
"typeVersion": 1.8
},
{
"id": "8469f6f8-e56e-433f-8439-ac0f568b01b1",
"name": "GPT-4o - Generate & Process Requests",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-360,
160
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "6h3DfVhNPw9I25nO",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "8f89996c-f5d1-48e3-8023-9c5d4c8db12a",
"name": "Memory - Track Recent Context",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
-180,
160
],
"parameters": {
"contextWindowLength": 50
},
"typeVersion": 1.3
},
{
"id": "ef32b577-47a2-489f-8b5a-3640126a0ff9",
"name": "Tool - Scrape Google Maps Business Data",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
160,
160
],
"parameters": {
"name": "extract_google_maps",
"workflowId": {
"__rl": true,
"mode": "list",
"value": "9rD7iD6sbXqDX44S",
"cachedResultName": "Google Maps - sous 1 - Extract Google maps"
},
"description": "Extract data from hundreds of places fast. Scrape Google Maps by keyword, category, location, URLs & other filters. Get addresses, contact info, opening hours, popular times, prices, menus & more. Export scraped data, run the scraper via API, schedule and monitor runs, or integrate with other tools.",
"workflowInputs": {
"value": {
"city": "={{ $fromAI('city', ``, 'string') }}",
"search": "={{ $fromAI('search', ``, 'string') }}",
"countryCode": "={{ $fromAI('countryCode', ``, 'string') }}",
"state/county": "={{ $fromAI('state_county', ``, 'string') }}"
},
"schema": [
{
"id": "search",
"type": "string",
"display": true,
"required": false,
"displayName": "search",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "city",
"type": "string",
"display": true,
"required": false,
"displayName": "city",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "state/county",
"type": "string",
"display": true,
"required": false,
"displayName": "state/county",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "countryCode",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "countryCode",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.1
},
{
"id": "86a6eafe-9ffc-4d58-85f7-eef7171eeb8e",
"name": "Fallback - Enrich with Google Search",
"type": "@n8n/n8n-nodes-langchain.toolSerpApi",
"position": [
-20,
160
],
"parameters": {
"options": {}
},
"credentials": {
"serpApi": {
"id": "FlfGC4PlqpLMJYRU",
"name": "SerpAPI account"
}
},
"typeVersion": 1
},
{
"id": "37409653-0409-4f2d-8105-9216f974f6a8",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-780,
-200
],
"parameters": {
"width": 1300,
"height": 540,
"content": "# AI-Powered Lead Generation Workflow
This workflow extracts business data from Google Maps and associated websites using an AI agent.
## Dependencies
- **OpenAI API**
- **Google Sheets API**
- **Apify Actors**: Google Maps Scraper
- **Apify Actors**: Website Content Crawler
- **SerpAPI**: Used as a fallback to enrich data
## External Setup Guide
**Notion** : [Guide](https://automatisation.notion.site/GOOGLE-MAPS-SCRAPER-1cc3d6550fd98005a99cea02986e7b05)
"
},
"typeVersion": 1
},
{
"id": "0b42dfae-49e6-4117-8a5d-d1f396f22dcb",
"name": "Tool - Crawl Business Website",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
340,
160
],
"parameters": {
"name": "Website_Content_Crawler",
"workflowId": {
"__rl": true,
"mode": "list",
"value": "I7KceT8Mg1lW7BW4",
"cachedResultName": "Google Maps - sous 2 - Extract Google"
},
"description": "Crawl websites and extract text content to feed AI models, LLM applications, vector databases, or RAG pipelines. The Actor supports rich formatting using Markdown, cleans the HTML, downloads files, and integrates well with 🦜🔗 LangChain, LlamaIndex, and the wider LLM ecosystem.",
"workflowInputs": {
"value": {},
"schema": [],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.1
},
{
"id": "8a713b20-99e6-4df1-88ce-698ffc3c1e31",
"name": "Trigger - On Subworkflow Start",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-460,
520
],
"parameters": {
"inputSource": "jsonExample",
"jsonExample": "{
\"search\": \"carpenter\",
\"city\": \"san francisco\",
\"state/county\": \"california\",
\"countryCode\": \"us\"
}"
},
"typeVersion": 1.1
},
{
"id": "59af012d-de3f-4a44-b3ad-e587857b554d",
"name": "Scrape Google Maps (via Apify)",
"type": "n8n-nodes-base.httpRequest",
"position": [
-240,
520
],
"parameters": {
"url": "https://api.apify.com/v2/acts/2Mdma1N6Fd0y3QEjR/run-sync-get-dataset-items",
"method": "POST",
"options": {},
"jsonBody": "={
\"city\": \"{{ $json.city }}\",
\"countryCode\": \"{{ $json.countryCode }}\",
\"locationQuery\": \"{{ $json.city }}\",
\"maxCrawledPlacesPerSearch\": 5,
\"searchStringsArray\": [
\"{{ $json.search }}\"
],
\"skipClosedPlaces\": false
}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer <token>"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "b1c40871-aa57-4b15-9f19-34a07dc6c45f",
"name": "Save Extracted Data to Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
-20,
520
],
"parameters": {
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "",
"cachedResultUrl": "",
"cachedResultName": ""
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "="
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "51us92xkOlrvArhV",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "679f2af5-0024-4a71-8c04-dcbccc8f00c8",
"name": "Aggregate Business Listings",
"type": "n8n-nodes-base.aggregate",
"position": [
200,
520
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "dff1191a-b9f4-4ba6-ba42-a479fab76a5b",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-780,
380
],
"parameters": {
"color": 4,
"width": 1300,
"height": 440,
"content": "# 📍 Google Maps Extractor Subworkflow
This subworkflow handles business data extraction from Google Maps using the Apify Google Maps Scraper.
## Purpose
- Automates the collection of business leads based on:
- Search term (e.g., plumber, agency)
- City and region
- ISO 3166 Alpha-2 country code"
},
"typeVersion": 1
},
{
"id": "dd691f9c-15e2-4b4a-a6eb-8765905a2cb4",
"name": "Scrape Website Content (via Apify)",
"type": "n8n-nodes-base.httpRequest",
"position": [
-320,
1000
],
"parameters": {
"url": "https://api.apify.com/v2/acts/aYG0l9s7dbB7j3gbS/run-sync-get-dataset-items",
"method": "POST",
"options": {},
"jsonBody": "={
\"aggressivePrune\": false,
\"clickElementsCssSelector\": \"[aria-expanded=\\"false\\"]\",
\"clientSideMinChangePercentage\": 15,
\"crawlerType\": \"playwright:adaptive\",
\"debugLog\": false,
\"debugMode\": false,
\"expandIframes\": true,
\"ignoreCanonicalUrl\": false,
\"keepUrlFragments\": false,
\"proxyConfiguration\": {
\"useApifyProxy\": true
},
\"readableTextCharThreshold\": 100,
\"removeCookieWarnings\": true,
\"removeElementsCssSelector\": \"nav, footer, script, style, noscript, svg, img[src^='data:'],\n[role=\\"alert\\"],\n[role=\\"banner\\"],\n[role=\\"dialog\\"],\n[role=\\"alertdialog\\"],\n[role=\\"region\\"][aria-label*=\\"skip\\" i],\n[aria-modal=\\"true\\"]\",
\"renderingTypeDetectionPercentage\": 10,
\"saveFiles\": false,
\"saveHtml\": false,
\"saveHtmlAsFile\": false,
\"saveMarkdown\": true,
\"saveScreenshots\": false,
\"startUrls\": [
{
\"url\": \"{{ $json.query }}\",
\"method\": \"GET\"
}
],
\"useSitemaps\": false
}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer apify_api_8UZf2KdZTkPihmNauBubgDsjAYTfKP4nsQSN"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "7cc813a7-e1a5-40fe-a76a-3e52438cf2f4",
"name": "Save Website Data to Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
-100,
1000
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "crawl",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "crawl",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "metadata",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "metadata",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "screenshotUrl",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "screenshotUrl",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "text",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "text",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "markdown",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "markdown",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "debug",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "debug",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1886744055,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JewfKbdS6gJhVFz0Maz6jpoDxQrByKyy77I5s7UvLD4/edit#gid=1886744055",
"cachedResultName": "MYWEBBASE"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1JewfKbdS6gJhVFz0Maz6jpoDxQrByKyy77I5s7UvLD4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JewfKbdS6gJhVFz0Maz6jpoDxQrByKyy77I5s7UvLD4/edit?usp=drivesdk",
"cachedResultName": "GoogleMaps_LEADS"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "51us92xkOlrvArhV",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "6c20b427-48e8-4ba1-885e-7db71406a0db",
"name": "Aggregate Website Content",
"type": "n8n-nodes-base.aggregate",
"position": [
120,
1000
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "7b1ff556-f212-4ab5-9995-deeb83f68da4",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-780,
860
],
"parameters": {
"color": 5,
"width": 1300,
"height": 400,
"content": "# 🌐 Website Content Crawler Subworkflow
This subworkflow processes URLs to extract readable website content using Apify's Website Content Crawler.
## Purpose
- Extracts detailed and structured content from business websites.
- Enhances leads with enriched, on-site information."
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "fd75b3e6-1dba-4e01-8c95-fdd9dd07fac4",
"connections": {
"Memory - Track Recent Context": {
"ai_memory": [
[
{
"node": "AI Agent - Lead Collection",
"type": "ai_memory",
"index": 0
}
]
]
},
"Tool - Crawl Business Website": {
"ai_tool": [
[
{
"node": "AI Agent - Lead Collection",
"type": "ai_tool",
"index": 0
}
]
]
},
"Scrape Google Maps (via Apify)": {
"main": [
[
{
"node": "Save Extracted Data to Google Sheets",
"type": "main",
"index": 0
}
]
]
},
"Trigger - On Subworkflow Start": {
"main": [
[
{
"node": "Scrape Google Maps (via Apify)",
"type": "main",
"index": 0
}
]
]
},
"Trigger - When User Sends Message": {
"main": [
[
{
"node": "AI Agent - Lead Collection",
"type": "main",
"index": 0
}
]
]
},
"Save Website Data to Google Sheets": {
"main": [
[
{
"node": "Aggregate Website Content",
"type": "main",
"index": 0
}
]
]
},
"Scrape Website Content (via Apify)": {
"main": [
[
{
"node": "Save Website Data to Google Sheets",
"type": "main",
"index": 0
}
]
]
},
"Fallback - Enrich with Google Search": {
"ai_tool": [
[
{
"node": "AI Agent - Lead Collection",
"type": "ai_tool",
"index": 0
}
]
]
},
"GPT-4o - Generate & Process Requests": {
"ai_languageModel": [
[
{
"node": "AI Agent - Lead Collection",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Save Extracted Data to Google Sheets": {
"main": [
[
{
"node": "Aggregate Business Listings",
"type": "main",
"index": 0
}
]
]
},
"Tool - Scrape Google Maps Business Data": {
"ai_tool": [
[
{
"node": "AI Agent - Lead Collection",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}
功能特点
- 自动检测新邮件
- AI智能内容分析
- 自定义分类规则
- 批量处理能力
- 详细的处理日志
技术分析
节点类型及作用
- @N8N/N8N Nodes Langchain.Chattrigger
- @N8N/N8N Nodes Langchain.Agent
- @N8N/N8N Nodes Langchain.Lmchatopenai
- @N8N/N8N Nodes Langchain.Memorybufferwindow
- @N8N/N8N Nodes Langchain.Toolworkflow
复杂度评估
配置难度:
维护难度:
扩展性:
实施指南
前置条件
- 有效的Gmail账户
- n8n平台访问权限
- Google API凭证
- AI分类服务订阅
配置步骤
- 在n8n中导入工作流JSON文件
- 配置Gmail节点的认证信息
- 设置AI分类器的API密钥
- 自定义分类规则和标签映射
- 测试工作流执行
- 配置定时触发器(可选)
关键参数
| 参数名称 | 默认值 | 说明 |
|---|---|---|
| maxEmails | 50 | 单次处理的最大邮件数量 |
| confidenceThreshold | 0.8 | 分类置信度阈值 |
| autoLabel | true | 是否自动添加标签 |
最佳实践
优化建议
- 定期更新AI分类模型以提高准确性
- 根据邮件量调整处理批次大小
- 设置合理的分类置信度阈值
- 定期清理过期的分类规则
安全注意事项
- 妥善保管API密钥和认证信息
- 限制工作流的访问权限
- 定期审查处理日志
- 启用双因素认证保护Gmail账户
性能优化
- 使用增量处理减少重复工作
- 缓存频繁访问的数据
- 并行处理多个邮件分类任务
- 监控系统资源使用情况
故障排除
常见问题
邮件未被正确分类
检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。
Gmail认证失败
确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。
调试技巧
- 启用详细日志记录查看每个步骤的执行情况
- 使用测试邮件验证分类逻辑
- 检查网络连接和API服务状态
- 逐步执行工作流定位问题节点
错误处理
工作流包含以下错误处理机制:
- 网络超时自动重试(最多3次)
- API错误记录和告警
- 处理失败邮件的隔离机制
- 异常情况下的回滚操作